#ifndef QABSTRACTTREENODE_H
#define QABSTRACTTREENODE_H

#include <QList>
#include <QVariant>
#include <QModelIndex>

class QAbstractTreeModel;

class QAbstractTreeNode : public QObject
{
    Q_OBJECT
protected:
    QAbstractTreeNode* m_parent;
    QList<QAbstractTreeNode*> m_children;
    QAbstractTreeModel* treeModel;

public:
    QAbstractTreeNode(QAbstractTreeNode* parent = NULL);
	virtual ~QAbstractTreeNode();
	QAbstractTreeNode* parent();
	QAbstractTreeNode* childAt(int index);
    int childCount() const;
	int row() const;
	virtual int columnCount() const = 0;
    virtual void addChild(QAbstractTreeNode* child);
    virtual void insertChild(QAbstractTreeNode* child, int after);
	virtual bool removeChild(int index);
    virtual bool insertColumns(int position, int count);
	virtual bool removeColumns(int position, int count);
    virtual QVariant data(int column, int role) const = 0;
    virtual bool setData(QVariant data, int column, int role);

    void removeAllChildren();

    virtual Qt::ItemFlags flags(int column = 0) const;

    QModelIndex index();

    void setModel(QAbstractTreeModel* model) { treeModel = model; }
    QAbstractTreeModel *model();

signals:
    void layoutAboutToBeChanged();
    void layoutChanged();

};

#endif // QABSTRACTTREENODE_H
